<?php

namespace app\index\controller;

use app\index\model\Routers;
use think\Controller;
use think\Facade\Request;
class Log extends Controller
{
    /**
     * 记录页面出现的异常
     * @return mixed
     */
    public function debug()
    {
        if (Request::isPost()) {
            $message = Request::post('message');
            $filename = Request::post('filename');
            $lineno   =Request::post('lineno');
            $ip = Request::ip();
            $log = date('Y-m-d H:i:s') . " [ IP:{$ip} FILE:{$filename} =>{$lineno}  MESSAGE:{$message} ] " . PHP_EOL;
            file_put_contents('./log/'.date('Ymd') . '.log', $log, FILE_APPEND);
            returnAjax('200', 'SUCCESS');
        }
    }

}
